<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        .da{
            width: 600px;
            height: 600px;
            border: 3px dashed black;
            position: absolute;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;
            margin: auto;
        }
        input{
            width: 400px;
            margin-left: 50px;
        }
        h3{
           text-align: center;
        }
        button{
            width: 50px;
            background-color: #00008b;
            color: #fff;
        }
        .tj{
            
            margin-left: 10px;
        }
        p{
            text-align: center;
            margin-top: 50px;
        }
        thead tr th{
            width: 200px;
            height: 30px;
        }
        table{
            margin: auto;
        }
        .sj{
            font-size: 12px;
        }
    </style>
</head>
<body>
    <p>积云教育-鸿蒙</p>
    <div class="da">
        <h3>任务记录</h3>
        <input type="text"><button class="tj" onclick="tj()">添加</button>
        <table>
            <thead align="center">
            <tr>
                <th>需要完成的任务</th>
                <th>时间</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody align="center">
            <!-- <tr>
                <td>123</td>
                <td>13</td>
                <td><button onclick='wc()'>完成</button><button onclick="sc(this)">删除</button></td>
            </tr> -->
        </tbody>
        </table>
    </div>
</body>
</html>
<script>
    var tb=document.querySelector("tbody")
    var input=document.querySelector("input")
    var wc=document.querySelector(".wc")
    function time(){
        var date=new Date()
        var sfm=date.toLocaleString().split(" ")[1]
        var xq=date.getDay();
        var arr='日一二三四五六'
        var xinqi;
        for(i=0;i<arr.length;i++){
            xinqi=arr[xq]
        }
        var n=date.getFullYear();
        var y=date.getMonth();
        var r=date.getDate()
        return `${n}年${y+1}月${r}日${sfm} 星期${xinqi}`
    }
    function tj(){
        var tr=document.createElement('tr')
        tr.innerHTML=`
                <td class='sj'>${input.value}</td>
                <td class='sj'>${time()}</td>
                <td><button onclick='cc(this)'>完成</button><button onclick="sc(this)">删除</button></td>
        `;
        tb.appendChild(tr)
        input.value=''
    }
    function cc(aa){
        aa.parentNode.parentNode.style.textDecoration='line-through'
    }
    function sc(a){
        tb.removeChild(a.parentNode.parentNode)
    }
</script>